import type { SysUser } from './model';

import type { ID, PageResult } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  userDelete = '/user/v1/deleteUser',
  userList = '/user/v1/pageList',
  userSave = '/user/v1/save',
  userUpdate = '/user/v1/update',
}

/**
 * 用户分页列表
 * @param data 请求参数
 * @returns 列表
 */
export function userList(data?: any) {
  return requestClient.post<PageResult<SysUser>>(Api.userList, data);
}

/**
 * 新增用户
 * @param data 参数
 */
export function userAdd(data: Partial<SysUser>) {
  return requestClient.postWithMsg<void>(Api.userSave, data);
}

/**
 * 更新用户
 * @param data 参数
 */
export function userUpdate(data: Partial<SysUser>) {
  return requestClient.postWithMsg<void>(Api.userUpdate, data);
}

/**
 * 删除用户
 * @param userId 用户ID
 */
export function userRemove(userId: ID) {
  return requestClient.get<void>(`${Api.userDelete}?id=${userId}`);
}
